import 'package:flutter/material.dart';
import 'package:flutter_chat/common/style/styles.dart';
import 'package:flutter_chat/common/widget/widgets.dart';
import 'package:flutter_chat/pages/index.dart';
import 'package:get/get.dart';
import 'package:line_icons/line_icons.dart';

class ApplicationPage extends GetView<ApplicationLogic> {
  const ApplicationPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      return Scaffold(
        appBar: customAppBar("聊天APP"),
        body: _buildPageView(),
        bottomNavigationBar: _buildBottomNavigationBar(),
      );
    });
  }

  Widget _buildPageView() {
    return PageView(
      physics: const NeverScrollableScrollPhysics(),
      controller: controller.pageController,
      children: const [
        MessagePage(),
        ContactsPage(),
        UserPage(),
      ],
    );
  }

  Widget _buildBottomNavigationBar() {
    return BottomNavigationBar(
      backgroundColor: Colors.white,
      type: BottomNavigationBarType.fixed,
      currentIndex: controller.state.selectedPageIndex,
      selectedFontSize: AppTheme.smallFont,
      unselectedFontSize: AppTheme.smallFont,
      items: const [
        BottomNavigationBarItem(
          icon: Icon(LineIcons.comments),
          label: "消息",
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.people_outline),
          label: "联系人",
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.person_outline),
          label: "我",
        )
      ],
      onTap: controller.onClickNavBar,
    );
  }
}
